<template>
  <div class="p_item" >
    <div class="play" @click="playFoo">
      <van-icon name="pause-circle-o" v-if="isPlay" />
      <van-icon name="play-circle-o" v-else />
    </div>

    <div :class="['title', isPlay == true ? 'active' : '']" @click="goSound">
      {{ title }}
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      play: false,
    };
  },
  props: {
    id: {
      type: Number,
    },
    albumId: {
      type: Number,
    },
    anchorId: {
      type: Number,
    },
    title: {
      type: String,
    },
    isPlay: {
      type: Boolean,
    },
    playPath:{
      tyeo:String
    }
  },
  watch: {
    isPlay: {
      immediate: true,
      deep: true,
      handler(val) {
        this.play = val;
      },
    },
  },
  methods: {
    playFoo() {
      this.play = !this.isPlay;
      console.log(this.play);
      this.$emit("play-pause", { id: this.id, isPlay: this.play });
    },

    goAlbum(id) {
      this.$router.push("/album/" + id);
    },

    goSound(){
      this.$router.push("/sound/" + this.id);
    }
  },
};
</script>

<style lang="scss" scoped>
.p_item {
  padding: 11px 0;

  display: flex;
  .title {
    font-size: 16px;
    font-weight: 500;
    color: #999;
    line-height: 26px;
    padding: 0 10px;
    margin-top: 1px;
  }
  .title.active {
    color: #f86442;
  }
  .play {
    height: 26px;
    width: 26px;
    font-size: 26px;
    color: #999;
  }
}
</style>

